﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;
using Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// A SuperRow is a tuple of Key and a SuperSlice.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="SN"></typeparam>
    /// <typeparam name="N"></typeparam>
    /// <typeparam name="V"></typeparam>
    public class SuperRowImpl<K, SN, N, V> : SuperRow<K, SN, N, V>
    {
        public SuperRowImpl(K bs, List<SuperColumn> thriftSuperColumns,
            Serializer<SN> sNameSerializer, Serializer<N> nameSerializer, 
            Serializer<V> valueSerializer)
        {
            if (bs == null || thriftSuperColumns == null || nameSerializer == null || valueSerializer == null)
            {
                throw new NullReferenceException("Key, SuperColumn, Name serializer and Value serializer cannot be null");
            }
            Key = bs;
            SuperSlice = new SuperSliceImpl<SN, N, V>(thriftSuperColumns, sNameSerializer, nameSerializer,
                valueSerializer);
        }
        public K Key
        {
            get;
            set;
        }
        public SuperSlice<SN, N, V> SuperSlice
        {
            get;
            set;
        }
        public override string ToString()
        {
            return "SuperRow(" + Key + "," + SuperSlice + ")";
        }
    }
}
